package net.keebook.webapp.util;
import java.math.BigInteger;
import java.security.MessageDigest;

public class Sha256 {
	public static String hash(String s) {
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("SHA-256");
		} catch (Exception e) {
			System.err.println("Could not get instance for SHA-256");
			return "";
		}
		md.update(s.getBytes());
		BigInteger hash = new BigInteger(1, md.digest());
		String stringHash = hash.toString(16);
		while (stringHash.length() < 64) {
			stringHash = "0" + stringHash;
		}
		return stringHash;
	}
}
